package com.ruoyi.hr.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hr.domain.TqwlhrPerformanceInfo;
import com.ruoyi.hr.service.ITqwlhrPerformanceInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 绩效考核项目Controller
 * 
 * @author ruoyi
 * @date 2022-07-19
 */
@RestController
@RequestMapping("/hr/Performance")
public class TqwlhrPerformanceInfoController extends BaseController
{
    @Autowired
    private ITqwlhrPerformanceInfoService tqwlhrPerformanceInfoService;

    /**
     * 查询绩效考核项目列表
     */
    @PreAuthorize("@ss.hasPermi('hr:Performance:list')")
    @GetMapping("/list")
    public TableDataInfo list(TqwlhrPerformanceInfo tqwlhrPerformanceInfo)
    {
        startPage();
        List<TqwlhrPerformanceInfo> list = tqwlhrPerformanceInfoService.selectTqwlhrPerformanceInfoList(tqwlhrPerformanceInfo);
        return getDataTable(list);
    }

    /**
     * 导出绩效考核项目列表
     */
    @PreAuthorize("@ss.hasPermi('hr:Performance:export')")
    @Log(title = "绩效考核项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TqwlhrPerformanceInfo tqwlhrPerformanceInfo)
    {
        List<TqwlhrPerformanceInfo> list = tqwlhrPerformanceInfoService.selectTqwlhrPerformanceInfoList(tqwlhrPerformanceInfo);
        ExcelUtil<TqwlhrPerformanceInfo> util = new ExcelUtil<TqwlhrPerformanceInfo>(TqwlhrPerformanceInfo.class);
        util.exportExcel(response, list, "绩效考核项目数据");
    }

    /**
     * 获取绩效考核项目详细信息
     */
    @PreAuthorize("@ss.hasPermi('hr:Performance:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(tqwlhrPerformanceInfoService.selectTqwlhrPerformanceInfoById(id));
    }

    /**
     * 新增绩效考核项目
     */
    @PreAuthorize("@ss.hasPermi('hr:Performance:add')")
    @Log(title = "绩效考核项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TqwlhrPerformanceInfo tqwlhrPerformanceInfo)
    {
        return toAjax(tqwlhrPerformanceInfoService.insertTqwlhrPerformanceInfo(tqwlhrPerformanceInfo));
    }

    /**
     * 修改绩效考核项目
     */
    @PreAuthorize("@ss.hasPermi('hr:Performance:edit')")
    @Log(title = "绩效考核项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TqwlhrPerformanceInfo tqwlhrPerformanceInfo)
    {
        return toAjax(tqwlhrPerformanceInfoService.updateTqwlhrPerformanceInfo(tqwlhrPerformanceInfo));
    }

    /**
     * 删除绩效考核项目
     */
    @PreAuthorize("@ss.hasPermi('hr:Performance:remove')")
    @Log(title = "绩效考核项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tqwlhrPerformanceInfoService.deleteTqwlhrPerformanceInfoByIds(ids));
    }
}
